<template>
  <div>
    <query-table ref="project_query_table" :page-size="20" :columns="columns"
                 :append-buttons="appendQueryButtons" :query-fields="queryFields"
                 :detail-fields="infoFields" base-url="/cost_standard_version"
                 show-index></query-table>
  </div>
</template>

<script>
  export default {
    name: "CostList",
    data() {
      return {
        //展示列信息
        columns: [
          {id: 'year', name: '发布年度', width: 80, type: 'user'},
          {id: 'name', name: '成本取值标准名称', align: 'left'},
          {id: 'targetOffice', name: '目标单位', width: 100, type: 'office',isHide:()=>{
              return !this.$store.state.user.admin;
            }},
          {id: 'createTime', name: '创建时间', width: 150},
          {id: 'createUser', name: '创建人', type: 'user', width: 90},
          {id: 'publishTime', name: '发布时间', width: 150},
          {id: 'publishUser', name: '发布人', type: 'user', width: 90},
          {
            id: 'state', name: '状态', component: {
              id: 'tag', getType: (val) => {
                if (val == 'publish') {
                  return 'success';
                }
              }
            }, width: 80, type:'meta',source:'cost-version-state'
          },
          {
            id: 'operation', name: '操作', type: 'button', width: 230, children: [
              {
                text: '查看', click: (row) => {
                  this.openPage('/cost/publish',row.id)
                },
              },
              {
                text: '编辑', operation: 'edit', isHide: (data) => {
                  //如果成本取值参数录入及查看权限都没有，则隐藏
                  return !this.checkPermission('cost_standard:record') || data.state == 'publish';
                }
              },
              // {
              //   text: '查看', operation: 'view', isHide: (data) => {
              //     //如果可研参数录入及查看权限都没有，则隐藏
              //     return data.state != 'publish';
              //   }
              // },
              {
                text: '删除', type: 'danger', operation: 'delete', isHide: (data) => {
                  //如果成本取值参数录入及查看权限都没有，则隐藏
                  return !this.checkPermission('cost_standard:record') || data.state == 'publish';
                }
              },
            ]
          },
        ],
        //查询条件字段
        queryFields: [
          {id: 'name', name: '版本名称', colSpan: 6},
          {id: 'year', name: '发布年度', component:'year-picker', colSpan: 5},
          {id: 'targetOffice', name: '目标单位', component:{id:'company-select',hideRoot:true},isHide:()=>{
              return !this.$store.state.user.admin;
            }, colSpan: 5},
          {id: 'state', name: '版本状态', component:{id:'meta-select',type:'cost-version-state'}, colSpan: 5},
        ],
        appendQueryButtons:[
          {text:'新增',permission:'cost_standard:record',type:'success',operation:'create'},
        ],
        infoFields: [{
          id: 'name',
          name: '版本名称',
          rules:[{ required: true, message: "请输入名称", trigger: "blur" }],
          colSpan:24,
          defaultValue:'油气田开发项目经济评价成本参数取值方法与标准'+new Date().getFullYear()+'版',
        }, {
          id: 'year',
          name: '发布年度',
          component: 'year-picker',
          defaultValue:new Date().getFullYear(),
          rules:[{ required: true, message: "请输入项目年度", trigger: "blur" }],
        },{
          id: 'targetOffice',
          name: '目标单位',
          component: {id:'data-select',dataUrl:'/company/tree'},
          isHide:()=>{
            return !this.$store.state.user.admin;
          }
        }, {
          id: 'remark',
          name: '备注',
          colSpan: 24,
          component: {
            id:'textarea',
            maxLength:200
          }
        } ],
      }
    },
    computed: {},
    created: function () {
    },
    methods: {
    },

  }
</script>